﻿using System;
using System.Data;


namespace DAL
{
    public static class DalInterview
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetInterview(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_Interview_Get");
        }
        public static DataTable GetInterviewEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Applicants_ID", id);
            return Cls.GetData("sp_Interview_Get_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtInterview obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Applicants_ID", obj.Applicants_ID);
            Cls.AddParameter("@Interview_Result", obj.Interview_Result);
            Cls.AddParameter("@Interview_Note", obj.Interview_Note);
            Cls.AddParameter("@Users_Id", obj.Users_Id);
            Cls.AddParameter("@DateBegin", obj.DateBegin);
            return Cls.ExecuteNonQuery("sp_Interview_Insert");
        }
        public static bool Update(EtInterview obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Interview_ID", obj.Interview_ID);
            Cls.AddParameter("@Applicants_ID", obj.Applicants_ID);
            Cls.AddParameter("@DateBegin", obj.DateBegin);
            return Cls.ExecuteNonQuery("sp_Interview_Update");
        }
        public static bool Review(EtInterview obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Interview_ID", obj.Interview_ID);
            Cls.AddParameter("@Interview_Result", obj.Interview_Result);
            Cls.AddParameter("@Interview_Note", obj.Interview_Note);
            return Cls.ExecuteNonQuery("sp_Interview_Review");
        }
        public static bool Delete(EtInterview obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Interview_ID", obj.Interview_ID);
            return Cls.ExecuteNonQuery("sp_Interview_Delete");
        }
        #endregion
    }

    public class EtInterview
    {
        public int Interview_ID { get; set; }
        public int? Applicants_ID { get; set; }
        public string Interview_Result { get; set; }
        public string Interview_Note { get; set; }
        public int? Users_Id { get; set; }
        public DateTime DateBegin { get; set; }
    }
}